# Contributor: Milan P. Stanić <mps@arvanta.net>
# Maintainer: team/rust <alpine@ptrcnull.me>
maintainer="team/rust <alpine@ptrcnull.me>"
pkgname=rust-bindgen
pkgver=0.70.1
pkgrel=0
pkgdesc="automatically generates Rust FFI bindings to C (and some C++) libraries"
url="https://github.com/rust-lang/rust-bindgen"
makedepends="cargo clang cargo-auditable"
checkdepends="bash clang-dev"
arch="all"
license="BSD-3-Clause"
options="net"
source="$pkgname-$pkgver.tar.gz::https://github.com/rust-lang/rust-bindgen/archive/v$pkgver.tar.gz
	disable-test_wrap_static_fns-patch
	"

prepare() {
	default_prepare

	case "$CARCH" in
	a*)
		# possibly https://github.com/rust-lang/rust-bindgen/issues/2777
		patch -Np1 < "$srcdir"/disable-test_wrap_static_fns-patch ;;
	esac

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --release --frozen
}

check() {
	cargo test --frozen
}

package() {
	install -Dm755 target/release/bindgen "$pkgdir"/usr/bin/bindgen
}

sha512sums="
dc1c43a3023a29597cfe8ef5f8a18c4ad9847d644545c0498c8253cbcd6eaf3377f38d73eb7275e849967e156f932e2644f21cfde444335a45bbd1260c575d07  rust-bindgen-0.70.1.tar.gz
c868005fe795cc064a6fe6df2018e7574ecb8c5a0031244b21c071ccdc8b391ed84a2eea5fb43f5c5bb69aedbbf0e4e2459b9a7facb0cb83ec1bdaf9ec16bce1  disable-test_wrap_static_fns-patch
"
